package com.sicheng.lc.周赛.分类.贪心;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zsc
 * @version 1.0
 * @date 2022/6/29 14:52
 */
public class 拆分成最多数目的正偶数之和 {
    //https://leetcode.cn/problems/maximum-split-of-positive-even-integers/
    static List<Long> res = new ArrayList<>();

    public List<Long> maximumEvenSplit(long finalSum) {
        if ((finalSum & 1) == 1)
            return res;
        long x = 2;
        ArrayList<Long> res = new ArrayList<>(100000);
        while (finalSum >= x) {
            res.add(x);
            finalSum -= x;
            x += 2;
        }
        if (finalSum > 0) {
            res.set(res.size() - 1, res.get(res.size() - 1) + finalSum);
        }
        return res;
    }
}
